<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    {include file="../tpl/header.html" /}
</head>
<body>
{include file="../tpl/menu.html" /}
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" method="post" action="">

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>角色</label>
                <div class="layui-input-block">
                    {foreach name="role_list" item="vo"}
                    <input type="radio" value="{$key}" name="role_id" lay-skin="primary" title="{$vo.name}" />
                    {/foreach}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>账号状态</label>
                <div class="layui-input-block">
                    <input type="radio" value="1" name="status" lay-skin="primary" title="启用" />
                    <input type="radio" value="2" name="status" lay-skin="primary" title="禁用" />
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>单点登录状态</label>
                <div class="layui-input-block">
                    <input type="radio" value="1" name="sso_status" lay-skin="primary" title="开启" />
                    <input type="radio" value="2" name="sso_status" lay-skin="primary" title="关闭" />
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>清楚错误次数</label>
                <div class="layui-input-block">
                    <input type="radio" value="0" name="error_num" lay-skin="primary" title="是" />
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <button class="layui-btn" lay-filter="add" lay-submit="">修改</button>
            </div>
        </form>
    </div>
</div>
<script>
    var ids = '{$uid}',success = 0,error = 0;

    layui.use(['form', 'layer'],
        function() {
            $ = layui.jquery;
            var form = layui.form, layer = layui.layer;
            //监听提交
            form.on('submit(add)', function(data) {
                var l = ids.split(',');
                for(var i = 0;i < l.length;i++){
                    data.field['uid'] = l[i];
                    $.ajax({
                        type:'post',
                        data:data.field,
                        dataType:'json',
                        url:"{:url('admin/admin/userEditOp')}",
                        async:false,
                        success:function (e) {
                            if(e.code === 1){
                                success++;
                            }else{
                                error++;
                            }
                            console.log(e)
                        }
                    });
                }
                layer.alert("成功:"+success.toString()+"个,失败:"+error.toString()+"个.",function (e) {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    parent.location.reload();
                });
                return false;
            });
        });
</script>
</body>
</html>